﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
using System.Data;
using CMP.ERP.Model;
using CMP.ERP.Helper;

namespace CMP.ERP.DAL
{
  public  class WeighDAL
    {
      /// <summary>
        /// 实例化SQLHelper对象
      /// </summary>
      SQLHelper sql = new SQLHelper();
       /// <summary>
       /// 称重显示
       /// </summary>
       /// <returns></returns>
        public DataTable GetShow()
        {

            string str = "select Weigh_id,Weigh_money,Weigh_kilogram,Weigh_danhao,Shipments_Per,Shipments_Phone from Weigh  join Shipments on Weigh.Shipments_Id=Shipments.Shipments_Id";
            return sql.ExecDataTable(str);

        }
      /// <summary>
      /// 添加称重物品
      /// </summary>
      /// <param name="w"></param>
      /// <returns></returns>
        public int Getadd(int  Shipments_Id,int  Weigh_money,string  Weigh_kilogram,string  Weigh_danhao)
        {
            string str =string.Format("insert into Weigh(Shipments_Id,Weigh_money,Weigh_kilogram,Weigh_danhao) values ("+Shipments_Id+","+Weigh_money+",'"+Weigh_kilogram+"','"+Weigh_danhao+"')");
            return sql.ExecNonquery(str);
        }
        /// <summary>
        /// 根据单号查询
        /// </summary>
        /// <param name="name"></param>
        /// <returns></returns>
        public DataTable Getchaxun(string danhao)
        {
            string str = string.Format("select Weigh_id,Weigh_money,Weigh_kilogram,Weigh_danhao,Shipments_Per,Shipments_Phone from Weigh  join Shipments on Weigh.Shipments_Id=Shipments.Shipments_Id  where Weigh.Weigh_danhao='"+danhao+"'");
            return sql.ExecDataTable(str);
        }
        /// <summary>
        /// 下拉框
        /// </summary>
        /// <param name="name"></param>
        /// <returns></returns>
        public DataTable Getxiala()
        {
            string str = "select Shipments_Id,Shipments_Per from Shipments";
            return sql.ExecDataTable(str);
        }
      /// <summary>
      /// 删除
      /// </summary>
      /// <param name="id"></param>
      /// <returns></returns>
      public int Getdelete(int id)
        {
            string str = "delete Weigh where Weigh_Id="+id+"";
            return sql.ExecNonquery(str);
        }
    }
}
